<template>
  <!--顶部导航栏-->
  <div>
    <div class="cinema-nav-box">
      <div class="cinema-city" @click="navToCity()">
        <div>{{ currentCity }}</div>
        <div class="icon icon-arrow-down"></div>
      </div>
      <div class="title-bar">影院</div>
      <div class="search-bar icon icon-search"></div>
    </div>
  </div>

  <!--快捷导航栏--->
  <div>
    <van-tabs
      v-model:active="currentType"
      title-active-color="#ff5f16"
      color="#ff5f16"
      sticky
    >
      <van-tab
        v-for="(item, index) in cinemaType"
        :title="item"
        :key="index"
      ></van-tab>
      <div class="cinema-box">
        <div v-for="(item, index) in cinemaList" :key="index">
          <div class="cinema-item">
            <div class="cinema-info">
              <div class="cinema-title">{{ item.title }}</div>
              <div class="cinema-address">{{ item.address }}</div>
            </div>
            <div class="cinema-distance">{{ item.ad_info.district }}</div>
          </div>
        </div>
      </div>
    </van-tabs>
  </div>
</template>
<script setup>
import { ref, onMounted } from "vue";
import { useStore } from "vuex";
const store = useStore();
const currentCity = ref(store._state.data.userCity);
const cinemaType = ["全城", "APP订票", "最近去过"];
const currentType = ref(0);
let cinemaList = ref(new Object());
onMounted(async () => {
  const tempData = await fetch(
    "/map/ws/place/v1/search?boundary=region(" +
      store._state.data.userCity +
      ",0)&keyword=影院&page_size=20&page_index=1&key=LOBBZ-LFSWU-7OMV7-2OFVB-MFTX7-KGB66"
  ).then((data) => data.json());
  for (let i = 0; i < tempData.data.length; i++) {
    tempData.data[i]._distance = parseInt(tempData.data[i]._distance) + "m";
  }
  cinemaList.value = tempData.data;
});
</script>
<style>
.cinema-nav-box {
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  height: 40px;
  line-height: 40px;
}
.cinema-city {
  position: absolute;
  left: 10px;
  font-size: 12px;
  display: flex;
}

.cinema-city .icon {
  margin-left: 2px;
  font-size: 12px;
}
.search-bar {
  position: absolute;
  right: 10px;
}
.cinema-box {
  margin-top: 30px;
  margin-bottom: 80px;
}
.cinema-item {
  padding: 10px 20px;
  box-sizing: border-box;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 1px #f8f8f8 solid;
}
.cinema-info {
  width: 80%;
}
.cinema-title {
  font-size: 14px;
}
.cinema-address {
  font-size: 12px;
  color: #797d82;
}
.cinema-distance {
  color: #ff5f16;
  font-size: 14px;
}
</style>
